home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5011 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
  4. Subject: Re: Undefined behavior? on type conversion, was: Re: Hungarian notation
  5. Date: Fri, 02 Feb 1996 03:53:33 GMT
  6. Organization: Netcom
  7. Message-ID: <31118641.6802368@nntp.ix.netcom.com>
  8. References: <30C40F77.53B5@swsbbs.com> <4d2ok0$69s@beach.and.nl> <4er2qo$h2s@galaxy.ucr.edu>
  9. NNTP-Posting-Host: ix-dc11-10.ix.netcom.com
  10. X-NETCOM-Date: Thu Feb 01  7:54:13 PM PST 1996
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. thp@cs.ucr.edu (Tom Payne) wrote:
  14.  
  15. > James Kanze US/ESC 60/3/141 #40763 (kanze@lts.sel.alcatel.de) wrote:
  16. > : miker3@ix.netcom.com (Mike Rubenstein) writes:
  17. > : [...]
  18. > : |> Is it really necessary to post this kind of nonsense.  No, the
  19. > : |> documentation may not say the result is to delete your system disk.
  20. > : |> Repeating the quote from ISO 6.2.1.2
  21. > : 
  22. > : |>     When a value with integral type is demoted to a signed integer
  23. > : |>     with smaller size or an unsigned integer is converted to its 
  24. > : |>     corresponding signed integer, if the value cannot be 
  25. > : |>     represented the result is implementation defined.
  26. > : 
  27. > : |> This requires an implementation to convert the integral type.  It does
  28. > : |> not give it license to take actions not specified by the standard.
  29. > : 
  30. > : Does it?  I believe that it was the intent of the authors that the
  31. > : `result' of the conversion could be a signal (for example) or a core
  32. > : dump.  (This is, of course, the only reasonable thing for an
  33. > : implementation to do.)
  34. > In 6.2.1.2, quoted above, it is not clear whether "result" refers to
  35. > the "resulting value" or to the "resulting behavior".  IMHO, it should
  36. > unambiguously refer to the former --- I see no need to open the door
  37. > to the various shenanigans that standard euphemistically calls,
  38. > "undefined behavior."  
  39.  
  40. I certainly wouldn't argue against the claim that it should be made
  41. clearer -- obviously there is some difference of opinion.
  42.  
  43. But, I don't see how one can claim the conversion may not be done.
  44. 6.3.4 says
  45.  
  46.     Preceding an expression by a parenthesized type name converts 
  47.     the value to the named type.
  48.  
  49. Consider a machine with 8 bit char and the expression
  50.  
  51.     (char) 256
  52.  
  53. Here we have correct syntax and correct data.  The standard says that
  54. this converts the number 256 to a char.  I believe I have a right to
  55. assume that this will be done.
  56.  
  57.  
  58. Michael M Rubenstein
  59.